72 lines
2.4 KiB
C
72 lines
2.4 KiB
C
// The MIT License (MIT)
|
|
//
|
|
// Copyright (C) 2026 Scott Duensing
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
// of this software and associated documentation files (the "Software"), to
|
|
// deal in the Software without restriction, including without limitation the
|
|
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
// sell copies of the Software, and to permit persons to whom the Software is
|
|
// furnished to do so, subject to the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included in
|
|
// all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
// IN THE SOFTWARE.
|
|
|
|
// nullDrv.c -- the null sound driver (null.drv)
|
|
//
|
|
// Plays nothing and accepts everything, so programs work the same on a
|
|
// computer without sound hardware: voices still run their course (and
|
|
// report their end) because the timer service drives the mixer, at a
|
|
// low rate and into a buffer nobody hears. Tried last.
|
|
|
|
#include "audioDrv.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
// Mix as little as the voices need to keep time
|
|
#define NULL_RATE 11025
|
|
#define NULL_BITS 8
|
|
#define NULL_CHANNELS 1
|
|
|
|
// ============================================================
|
|
// Prototypes
|
|
// ============================================================
|
|
|
|
static void nullClose(void);
|
|
static bool nullOpen(const AudioDrvConfigT *cfg, AudioDrvInfoT *info);
|
|
static bool nullPlay(void);
|
|
|
|
AUDIO_DRIVER("null", AUDIO_PRIORITY_NULL,
|
|
.open = nullOpen,
|
|
.play = nullPlay,
|
|
.close = nullClose
|
|
);
|
|
|
|
|
|
static void nullClose(void) {
|
|
audioClockStop();
|
|
}
|
|
|
|
|
|
static bool nullOpen(const AudioDrvConfigT *cfg, AudioDrvInfoT *info) {
|
|
(void)cfg;
|
|
|
|
snprintf(info->description, sizeof(info->description), "No sound device");
|
|
info->rate = NULL_RATE;
|
|
info->bits = NULL_BITS;
|
|
info->channels = NULL_CHANNELS;
|
|
return true;
|
|
}
|
|
|
|
|
|
static bool nullPlay(void) {
|
|
return audioClockStart();
|
|
}
|