Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD: Rewrite OSS backend, introduce sosso library #943

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
492 changes: 492 additions & 0 deletions freebsd/oss/JackOSSChannel.cpp

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions freebsd/oss/JackOSSChannel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
Copyright (C) 2003-2007 Jussi Laako <[email protected]>
Copyright (C) 2008 Grame & RTL 2008

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#ifndef __JackOSSChannel__
#define __JackOSSChannel__

#include "JackMutex.h"
#include "JackThread.h"
#include "sosso/Correction.hpp"
#include "sosso/DoubleBuffer.hpp"
#include "sosso/FrameClock.hpp"
#include "sosso/ReadChannel.hpp"
#include "sosso/WriteChannel.hpp"

namespace Jack
{

typedef jack_default_audio_sample_t jack_sample_t;

/*!
\brief The OSS driver.
*/

class JackOSSChannel : public JackRunnableInterface
{

private:
JackThread fAssistThread;
JackProcessSync fMutex;
sosso::FrameClock fFrameClock;
sosso::DoubleBuffer<sosso::ReadChannel> fReadChannel;
sosso::DoubleBuffer<sosso::WriteChannel> fWriteChannel;
sosso::Correction fCorrection;

std::int64_t fFrameStamp = 0;

public:

JackOSSChannel() : fAssistThread(this)
{}
virtual ~JackOSSChannel()
{}

sosso::DoubleBuffer<sosso::ReadChannel> &Capture()
{
return fReadChannel;
}

sosso::DoubleBuffer<sosso::WriteChannel> &Playback()
{
return fWriteChannel;
}

sosso::FrameClock &FrameClock()
{
return fFrameClock;
}

bool Lock()
{
return fMutex.Lock();
}

bool Unlock()
{
return fMutex.Unlock();
}

void SignalWork()
{
fMutex.SignalAll();
}

bool InitialSetup(unsigned sample_rate);

bool OpenCapture(const char* device, bool exclusive, int bits, int &channels);
bool OpenPlayback(const char* device, bool exclusive, int bits, int &channels);

bool Read(jack_sample_t** sample_buffers, jack_nframes_t length, std::int64_t end);
bool Write(jack_sample_t** sample_buffers, jack_nframes_t length, std::int64_t end);

bool StartChannels(unsigned buffer_frames);
bool StopChannels();

bool StartAssistThread(bool realtime, int priority);
bool StopAssistThread();

bool CheckTimeAndRun();

bool Sleep() const;

bool CaptureFinished() const;
bool PlaybackFinished() const;

std::int64_t PlaybackCorrection();

virtual bool Init();

virtual bool Execute();

std::int64_t XRunGap() const;

void ResetBuffers(std::int64_t offset);

std::int64_t FrameStamp() const
{
return fFrameStamp;
}

std::int64_t NextWakeup() const;
};

} // end of namespace

#endif
Loading
Loading