예제 #1
0
int
main(int argc, char** argv)
{
    int res;
    wchar_t* filename; wchar_t* storename; wchar_t* sourcename;
    int index;

    IStorage* storage;

    if (argc < 4) {
        (void)do_help(argc, argv);
        return 1;
    }
    filename = strdupwstr(argv[1]);
    index = atoi(argv[3]);
    sourcename = strdupwstr(argv[2]);
    
    res = OpenStore(filename, TRUE, &storage);
    if (res == 0)
        fatal("Error opening store");
    free(filename);

    res = GetStreamName(storage, index, &storename);
    if (res == 0)
        fatal("Error geting store name");

    res = AddStore(storage, storename, sourcename);
    if (res == 0)
        fatal("Error adding store");

    (void)free(storename);
    (void)free(sourcename);
    (int)CloseStore(storage);
    return 0;
}
예제 #2
0
int
GetStorage(IStorage* storage, int index, IStorage** out)
{
    int res;
    wchar_t* name;
    STGTY type;

    assert(storage != NULL); assert(out != NULL);
    *out = NULL;

    res = GetStreamType(storage, index, &type);
    if ((res == 0) || (type != STGTY_STORAGE))
        return 0;

    res = GetStreamName(storage, index, &name);
    if (res == 0)
        return 0;

    res = storage->lpVtbl->OpenStorage(storage, name, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, NULL, 0, out);
    free(name);
    return (res == S_OK)? 1 : 0;
}
예제 #3
0
static FileOutputStream *InitialiseIO (const HashTable * const config_p, const char * const key_s, const char * const suffix_s)
{
	FileOutputStream *stream_p = NULL;
	const char * const output_dir_s = GetOutputDir ();

	/* Make sure that the output directory exists */
	if (EnsureDirectoryExists (output_dir_s))
		{
			char *output_filename_s = (char *) GetFromHashTable (config_p, "OutputFilename");

			/* Adapt the streams to be relative to our output directory */
			char *name_s = GetStreamName (output_dir_s, output_filename_s, (char *) GetFromHashTable (config_p, key_s), suffix_s);
			stream_p = AllocateFileOutputStream (name_s);

			if (name_s)
				{
					FreeCopiedString (name_s);
				}

		}		/* if (CreateNewDirectory (output_dir_s)) */

	return stream_p;
}
bool WaveOutPulseAudio::OpenWaveOutDevice(int pSampleRate, int pOutputChannels)
{
    pa_sample_spec     tOutputFormat;
    int                tRes;
    pa_usec_t          tLatency;

    LOG(LOG_VERBOSE, "Trying to open the wave out device");

    if (mWaveOutOpened)
        return false;

    mSampleRate = pSampleRate;
    mAudioChannels = pOutputChannels;

    LOG(LOG_VERBOSE, "Desired device is %s", mDesiredDevice.c_str());

    if ((mDesiredDevice == "") || (mDesiredDevice == "auto") || (mDesiredDevice == "automatic"))
    {
        LOG(LOG_VERBOSE, "Using default audio device");
        mDesiredDevice = "";
    }

    tOutputFormat.format = PA_SAMPLE_S16LE;
    tOutputFormat.rate = mSampleRate;
    tOutputFormat.channels = mAudioChannels;

    // create a new playback stream
    if (!(mOutputStream = pa_simple_new(NULL, "Homer-Conferencing", PA_STREAM_PLAYBACK, (mDesiredDevice != "" ? mDesiredDevice.c_str() : NULL) /* dev Name */, GetStreamName().c_str(), &tOutputFormat, NULL, NULL, &tRes)))
    {
        LOG(LOG_ERROR, "Couldn't create PulseAudio stream because %s(%d)", pa_strerror(tRes), tRes);
        return false;
    }

    if ((tLatency = pa_simple_get_latency(mOutputStream, &tRes)) == (pa_usec_t) -1)
    {
        LOG(LOG_ERROR, "Couldn't determine the latency of the output stream because %s(%d)", pa_strerror(tRes), tRes);
        pa_simple_free(mOutputStream);
        mOutputStream = NULL;
        return false;
    }

    mCurrentDevice = mDesiredDevice;

    //######################################################
    //### give some verbose output
    //######################################################
    LOG(LOG_INFO, "PortAudio wave out opened...");
    LOG(LOG_INFO,"    ..sample rate: %d", mSampleRate);
    LOG(LOG_INFO,"    ..channels: %d", pOutputChannels);
    LOG(LOG_INFO,"    ..desired device: %s", mDesiredDevice.c_str());
    LOG(LOG_INFO,"    ..selected device: %s", mCurrentDevice.c_str());
    LOG(LOG_INFO,"    ..latency: %"PRIu64" seconds", (uint64_t)tLatency * 1000 * 1000);
    LOG(LOG_INFO,"    ..sample format: %d", PA_SAMPLE_S16LE);

    mWaveOutOpened = true;

    return true;
}